package org.feng.resource;

import java.security.Principal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

import org.feng.entity.EntityPool;
import org.feng.entity.KeyUser;
import org.feng.entity.Menu;
import org.feng.entity.Operator;
import org.feng.entity.Role;
import org.feng.entity.User;

import io.quarkus.security.identity.SecurityIdentity;

@Path("/hello")
//@Produces(MediaType.APPLICATION_JSON)
//@Consumes(MediaType.APPLICATION_JSON)
public class ExampleResource {
   
 	//@Inject
	User mxUser=new User();
	//Role mxRole=null;
	//Menu mxMenu=null;
	//Operator mxOp=null;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    @Transactional
    public String hello() {
    	//mxUser.userName="你好";
    	//mxUser.setAge(12);
    	//mxUser.setBirthday(LocalDateTime.now());
    	//mxUser.persist();
    	//三首诗xxxx
        return "Hello RESTEasy";
    }
    
    @Inject
    SecurityIdentity si;

    @Path("listUser")
    @GET
    @Produces("application/json")
    public List<User> listUser() {
    	//if (mxUser==null)
    	//	mxUser=new User();
    	//return si.getAttribute("userInfo");
    	//return si.getPrincipal();User
    	//return si.getRoles();
    	return User.listAll();
    	
    	
    }
    
    @Path("listRole")
    @GET
    @Produces("application/json")
    public List<Role> listRole() {
    	//Role.class
    	//if (mxRole==null)
    	//	mxRole=new Role();
    	KeyUser ku=(KeyUser)(EntityPool.getEntityObject(KeyUser.class));
    	KeyUser kux=(KeyUser)(EntityPool.getEntityObject(KeyUser.class));
    	KeyUser kuy=(KeyUser)(EntityPool.getEntityObject(KeyUser.class));
    	KeyUser kuz=(KeyUser)(EntityPool.getEntityObject(KeyUser.class));
    	List kum=(List)(EntityPool.getListEntityObject(KeyUser.class,15));
    	List kum2=(List)(EntityPool.getListEntityObject(KeyUser.class,20));
    	
    	return Role.listAll();
    	
    }
    @Path("listMenu")
    @GET
    @Produces("application/json")
    public List<Menu> listMenu() {
    	//if (mxMenu==null)
    	//	mxMenu=new Menu();
    	return Menu.listAll();
    	
    }
    @Path("listOp")
    @GET
    @Produces("application/json")
    public List<Menu> listOp() {
    	//if (mxOp==null)
    	//	mxOp=new Operator();
    	return Operator.listAll();
    	
    }
    
    @Path("listAll")
    @GET
    @Produces("application/json")
    public List<List<?>> listAll() {
    	List<List<?>> listAll=new ArrayList<List<?>>();
    	//listAll.add(listUser());
    	listAll.add(listRole());
    	listAll.add(listMenu());
    	listAll.add(listOp());
     	return listAll;
    }
}